package nio.traditionalcopy;

import java.io.DataInputStream;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * 传统IO
 * 服务器端
 */
public class OldIOServer {

	public static void main(String[] args) throws Exception {
		// 监听 7001，端口
		ServerSocket serverSocket = new ServerSocket(7001);

		while (true) {
			// 监视连接
			Socket socket = serverSocket.accept();
			// 通过 serversocket 获得输入流
			DataInputStream dataInputStream = new DataInputStream(socket.getInputStream());

			try {
				byte[] byteArray = new byte[4096];

				// 循环的读取数据
				while (true) {
					int readCount = dataInputStream.read(byteArray, 0, byteArray.length);

					if (-1 == readCount) {
						break;
					}
				}
			} catch (Exception ex) {
				ex.printStackTrace();
			}
		}
	}
}
